<template>
  <view class="manufactor_container">
    <view class="floor_bargain_title">
      <image :src="staticUrl()+'/new/floor_brand_more.png'" class="more" @click="clickJumpInfo">
      </image>
    </view>

    <view class="bannerList" ref="bannerList">
      <image v-for="(i,j) in bannerList" :key="j" :src="i.imageUrl" mode="aspectFit"
        @click="clickJumpInfo(i.id,i.title)"></image>
    </view>

    <view class="goods_list">
      <swiper autoplay :interval="3000" circular @change="changeBanner(1,$event)">
        <swiper-item v-for="(ii, jj) in dataList1" :key="jj">
          <ImageCache :src="ii.billboardMobile" @click="clickJumpInfo(ii.id,ii.name)" class="img">
          </ImageCache>
        </swiper-item>
      </swiper>

      <view class="goods_list_item">
        <view v-for="(i,j) in skuList1.skuList" :key="j" class="item"
          @click="clickJumpInfo(skuList1.id,skuList1.name)">
          <image v-if="i.inform" mode="aspectFit" :src="i.inform" class="img inform_announcement">
          </image>
          <ImageCache class="img" :class="i.quantity ? '' : 'sellOut_container-img'"
            :src="i.original ? i.original : staticUrl() + '/home/defaultImg.png'"
            :mode="'aspectFit'" />
          <view class="goodsName singleRowEllipsis">
            <text class="goods_name "> {{ i.goodsName }} </text>
          </view>
          <view v-if="hasToken() && i.price">
            <view class="promotionPrice">
              <text class="coinSymbol">￥</text>
              <text class="price" v-if="i.price">{{ i.price }}</text>
              <text class="packing">/{{ i.goodsUnit }}</text>
            </view>
            <view class="originalPrice">
              <text class="price" v-if="i.originalPrice">￥{{ i.originalPrice }}</text>
            </view>
          </view>
          <view class="prices singleRowEllipsis" v-if="hasToken() && !i.price">
            <text class="login_see">资质审核可见</text>
          </view>
          <view class="prices" v-if="!hasToken()">
            <text class="login_see">登录可见</text>
          </view>
        </view>
      </view>
    </view>
    <view class="goods_list">
      <swiper autoplay :interval="3000" circular @change="changeBanner(2,$event)">
        <swiper-item v-for="(ii, jj) in dataList2" :key="jj">
          <ImageCache :src="ii.billboardMobile" @click="clickJumpInfo(ii.id,ii.name)" class="img">
          </ImageCache>
        </swiper-item>
      </swiper>

      <view class="goods_list_item">
        <view v-for="(i,j) in skuList2.skuList" :key="j" class="item"
          @click="clickJumpInfo(skuList2.id,skuList2.name)">
          <image v-if="i.inform" mode="aspectFit" :src="i.inform" class="img inform_announcement">
          </image>
          <ImageCache class="img" :class="i.quantity ? '' : 'sellOut_container-img'"
            :src="i.original ? i.original : staticUrl() + '/home/defaultImg.png'"
            :mode="'aspectFit'" />
          <view class="goodsName singleRowEllipsis">
            <span class="goods_name "> {{ i.goodsName }} </span>
          </view>
          <view v-if="hasToken() && i.price">
            <view class="promotionPrice">
              <text class="coinSymbol">￥</text>
              <text class="price" v-if="i.price">{{ i.price }}</text>
              <text class="packing">/{{ i.goodsUnit }}</text>
            </view>
          </view>
          <view class="prices singleRowEllipsis" v-if="hasToken() && !i.price">
            <text class="login_see">资质审核可见</text>
          </view>
          <view class="prices" v-if="!hasToken()">
            <text class="login_see">登录可见</text>
          </view>
        </view>
      </view>
    </view>
    <view class="goods_list">
      <swiper autoplay :interval="3000" circular @change="changeBanner(3,$event)">
        <swiper-item v-for="(ii, jj) in dataList3" :key="jj">
          <ImageCache :src="ii.billboardMobile" @click="clickJumpInfo(ii.id,ii.name)" class="img">
          </ImageCache>
        </swiper-item>
      </swiper>

      <view class="goods_list_item">
        <view v-for="(i,j) in skuList3.skuList" :key="j" class="item"
          @click="clickJumpInfo(skuList3.id,skuList3.name)">
          <image v-if="i.inform" mode="aspectFit" :src="i.inform" class="img inform_announcement">
          </image>
          <ImageCache class="img" :class="i.quantity ? '' : 'sellOut_container-img'"
            :src="i.original ? i.original : staticUrl() + '/home/defaultImg.png'"
            :mode="'aspectFit'" />
          <view class="goodsName singleRowEllipsis">
            <span class="goods_name "> {{ i.goodsName }} </span>
          </view>
          <view v-if="hasToken() && i.price">
            <view class="promotionPrice">
              <text class="coinSymbol">￥</text>
              <text class="price" v-if="i.price">{{ i.price }}</text>
              <text class="packing">/{{ i.goodsUnit }}</text>
            </view>
          </view>
          <view class="prices singleRowEllipsis" v-if="hasToken() && !i.price">
            <text class="login_see">资质审核可见</text>
          </view>
          <view class="prices" v-if="!hasToken()">
            <text class="login_see">登录可见</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>


<script>
import { getDedicatedData } from '@/api/home/index'

export default {
  props: {
    data: {
      type: Object,
      default: () => { }
    }
  },
  data () {
    return {
      bannerList: [],
      dataList1: [],
      dataList2: [],
      dataList3: [],
      skuList1: [],
      skuList2: [],
      skuList3: [],
    }
  },
  created () {
    getDedicatedData(this.data.bannerPath).then(res => {
      if (res.code === 200) {
        this.bannerList = res.data
        this.bannerList.push(...res.data)
      }
    })
    getDedicatedData(this.data.promotion.promotionGoodsPath).then(res => {
      if (res.code === 200) {
        res.data.forEach((e, f) => {
          if (f % 3 === 0) {
            this.dataList1.push(e)
          } else if (f % 3 === 1) {
            this.dataList2.push(e)
          } else {
            this.dataList3.push(e)
          }
        })
        this.skuList1 = this.dataList1[0]
        this.skuList2 = this.dataList2[0]
        this.skuList3 = this.dataList3[0]
      }
    })
  },
  methods: {
    changeBanner (i, e) {
      if (i === 1) {
        this.skuList1 = this.dataList1[e.detail.current]
      }
      if (i === 2) {
        this.skuList2 = this.dataList2[e.detail.current]
      }
      if (i === 3) {
        this.skuList3 = this.dataList3[e.detail.current]
      }
    },
    clickJumpInfo (id, name) {
      console.log(name)
      uni.navigateTo({
        url: `/subpackage/manufactor/index?url=${this.data.bannerPath}&id=${id}&content=${name}`
      })
    },
  }
}
</script>

<style lang="scss" scoped>
.manufactor_container {
  background-image: url("https://www.xdyy100.com/wholesale/files/mp/static/new/floor_brand.png");
  background-size: 100%;
  background-repeat: no-repeat;
  width: 702rpx;
  height: 910rpx;
  position: relative;
  overflow: hidden;
  .floor_bargain_title {
    position: absolute;
    top: 31rpx;
    right: 24rpx;
    .more {
      width: 104rpx;
      height: 44rpx;
    }
  }
  .bannerList {
    display: flex;
    flex-flow: row nowrap;
    margin-top: 87rpx;
    position: absolute;
    animation: scrollAnimation 300s linear infinite;
    image {
      width: 155rpx;
      height: 79rpx;
      background: #ffffff;
      box-shadow: 0rpx 1rpx 1rpx 0rpx rgba(40, 113, 252, 0.5);
      border-radius: 8rpx 8rpx 8rpx 8rpx;
      margin-right: 18rpx;
    }
  }
  @keyframes scrollAnimation {
    0% {
      transform: translateX(0);
    }
    100% {
      transform: translateX(-50%);
    }
  }
  .goods_list {
    width: 668rpx;
    height: 222rpx;
    border-radius: 8rpx 8rpx 8rpx 8rpx;
    margin-left: 16rpx;
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    swiper {
      width: 198rpx;
      height: 222rpx;
    }

    .goods_list_item {
      width: 446rpx;
      height: 206rpx;
      background: #ffffff;
      border-radius: 8rpx 8rpx 8rpx 8rpx;
      margin-left: 11rpx;
      display: flex;
      align-items: center;
      .item {
        width: 135rpx;
        height: 186rpx;
        border-radius: 8rpx 8rpx 8rpx 8rpx;
        border: 1rpx solid rgba(178, 178, 178, 0.73);
        display: flex;
        flex-flow: column nowrap;
        align-items: center;
        .img {
          margin: 8rpx;
          width: 119rpx;
          height: 72rpx;
        }
        .goodsName {
          width: 80%;
          font-size: 22rpx;
          color: #333333;
          text-align: center;
        }
        .promotionPrice {
          font-size: 26rpx;
          color: #ef231b;
          margin-top: 4rpx;
          .coinSymbol {
            font-size: 18rpx;
          }
          .price {
            font-weight: bold;
          }
          .packing {
            font-size: 18rpx;
            color: #999999;
          }
        }
        .originalPrice {
          .price {
            font-size: 18rpx;
            color: #999999;
            text-decoration-line: line-through;
          }
        }
        .prices {
          .login_see {
            font-size: 24rpx;
            color: #ef231b;
          }
        }
      }
      .item:nth-child(1) {
        margin-left: 12rpx;
      }
      .item:nth-child(2) {
        margin-left: 8rpx;
      }
      .item:nth-child(3) {
        margin-left: 8rpx;
      }
    }
  }
  .goods_list:nth-child(3) {
    background: #ffd2cc;
    margin-top: 187rpx;
  }
  .goods_list:nth-child(4) {
    background: #ccf4ee;
    margin-top: 16rpx;
  }
  .goods_list:nth-child(5) {
    background: #aac6ff;
    margin-top: 16rpx;
  }
}
</style>